package cn.edu.uestc.controller;

import cn.edu.uestc.service.SigninService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
public class SigninController {
    @Autowired
    HttpServletRequest request;
    @Autowired
    SigninService signinService;

    @PostMapping("sign_in")
    public boolean signin(String username, String password) {
        return signinService.signin(username, password);
    }

    @GetMapping("get_user_type")
    public int getUserType() {
        return (int) request.getSession().getAttribute("user_type");
    }
}
